package com.itheima.config;

import com.itheima.interceptors.Loginterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 功能：添加拦截器 拦截未登录用户
 * 作者：大风
 * 日期：2024/10/17 16:44
 */
@Configuration
public class InterceptorConfig implements WebMvcConfigurer {
    @Autowired
    private Loginterceptor loginterceptor;

    public void addInterceptors(InterceptorRegistry registry){
        //放行登录和注册
        registry.addInterceptor(loginterceptor).excludePathPatterns("/user/login","/user/register");
    }
}
